/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nanterre.annuaire.model;

import com.nanterre.annuaire.bd.BDInteraction;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author albran
 */
public class Ec extends ElementAnnuaire {

    private int fidResponsable;
    private String nomResponsable;
    private String prenomResponsable;
    private float nbCredit;
    private String mutualisable;
    private int volumeHeureCm;
    private int volumeHeureTd;
    private int volumeHeureTp;
    private int volumeHeureStage;
    private int volumeHeurMemoire;
    private int volumeHeurePerso;
    private int volumeHeureDistant;
    private int effectifCm;
    private int effectifTd;
    private int effectifTp;
    private String pourcentage;
    private String codeLMD2;
    private String modaliteEnseignement;
    private int numListeEc;
    private String contribution;

    public Ec() {
        super();
    }

    public int getNumListeEc() {
        return numListeEc;
    }

    public void setNumListeEc(int numListeEc) {
        this.numListeEc = numListeEc;
    }

    public String getNomResponsable() {
        return nomResponsable;
    }

    public void setNomResponsable(String nomResponsable) {
        this.nomResponsable = nomResponsable;
    }

    public String getPrenomResponsable() {
        return prenomResponsable;
    }

    public void setPrenomResponsable(String prenomResponsable) {
        this.prenomResponsable = prenomResponsable;
    }

    public String getCodeLMD2() {
        return codeLMD2;
    }

    public void setCodeLMD2(String codeLMD2) {
        this.codeLMD2 = codeLMD2;
    }

    public int getEffectifCm() {
        return effectifCm;
    }

    public void setEffectifCm(int effectifCm) {
        this.effectifCm = effectifCm;
    }

    public int getEffectifTd() {
        return effectifTd;
    }

    public void setEffectifTd(int effectifTd) {
        this.effectifTd = effectifTd;
    }

    public int getEffectifTp() {
        return effectifTp;
    }

    public void setEffectifTp(int effectifTp) {
        this.effectifTp = effectifTp;
    }

    public int getFidResponsable() {
        return fidResponsable;
    }

    public void setFidResponsable(int fidResponsable) {
        this.fidResponsable = fidResponsable;
    }

    public String getModaliteEnseignement() {
        return modaliteEnseignement;
    }

    public void setModaliteEnseignement(String modaliteEnseignement) {
        this.modaliteEnseignement = modaliteEnseignement;
    }

    public String getMutualisable() {
        return mutualisable;
    }

    public void setMutualisable(String mutualisable) {
        this.mutualisable = mutualisable;
    }

    public float getNbCredit() {
        return nbCredit;
    }

    public void setNbCredit(float nbCredit) {
        this.nbCredit = nbCredit;
    }

    public String getPourcentage() {
        return pourcentage;
    }

    public void setPourcentage(String pourcentage) {
        this.pourcentage = pourcentage;
    }

    public int getVolumeHeureCm() {
        return volumeHeureCm;
    }

    public void setVolumeHeureCm(int volumeHeureCm) {
        this.volumeHeureCm = volumeHeureCm;
    }

    public int getVolumeHeureDistant() {
        return volumeHeureDistant;
    }

    public void setVolumeHeureDistant(int volumeHeureDistant) {
        this.volumeHeureDistant = volumeHeureDistant;
    }

    public int getVolumeHeurMemoire() {
        return volumeHeurMemoire;
    }

    public void setVolumeHeurMemoire(int volumeHeurMemoire) {
        this.volumeHeurMemoire = volumeHeurMemoire;
    }

    public int getVolumeHeurePerso() {
        return volumeHeurePerso;
    }

    public void setVolumeHeurePerso(int volumeHeurePerso) {
        this.volumeHeurePerso = volumeHeurePerso;
    }

    public int getVolumeHeureStage() {
        return volumeHeureStage;
    }

    public void setVolumeHeureStage(int volumeHeureStage) {
        this.volumeHeureStage = volumeHeureStage;
    }

    public int getVolumeHeureTd() {
        return volumeHeureTd;
    }

    public void setVolumeHeureTd(int volumeHeureTd) {
        this.volumeHeureTd = volumeHeureTd;
    }

    public int getVolumeHeureTp() {
        return volumeHeureTp;
    }

    public void setVolumeHeureTp(int volumeHeureTp) {
        this.volumeHeureTp = volumeHeureTp;
    }

    public String getContribution() {
        return contribution;
    }

    public void setContribution(String contribution) {
//        this.contribution = "<b>toto</b>toto<h1>haha</h1><h3>ouai</h3>";
//        this.contribution = contribution.replace("\"", "&quot;");
//        this.contribution = contribution.replace("<", "&lt;");
//        this.contribution = contribution.replace(">", "&gt;");
        this.contribution = contribution;
    }

    public List<InfosEC> getInfos() {
        List<InfosEC> liste = new ArrayList<InfosEC>();
        InfosEC infosEc = new InfosEC("Credits", this.getNbCredit());
        liste.add(infosEc);
        if (this.getVolumeHeureCm() > 0) {
            infosEc = new InfosEC("CM", this.getVolumeHeureCm());
            liste.add(infosEc);
        }
        if (this.getVolumeHeureTd() > 0) {
            infosEc = new InfosEC("TD", this.getVolumeHeureTd());
            liste.add(infosEc);
        }
        if (this.getVolumeHeureTp() > 0) {
            infosEc = new InfosEC("TP", this.getVolumeHeureTp());
            liste.add(infosEc);
        }
        if (this.getVolumeHeureStage() > 0) {
            infosEc = new InfosEC("Stage", this.getVolumeHeureStage());
            liste.add(infosEc);
        }
        if (this.getVolumeHeurMemoire() != 0) {
            infosEc = new InfosEC("Memoire", this.getVolumeHeurMemoire());
            liste.add(infosEc);
        }
        if (this.getVolumeHeurePerso() != 0) {
            infosEc = new InfosEC("Tr. Perso", this.getVolumeHeurePerso());
            liste.add(infosEc);
        }


        return liste;


    }

    public String infoBulle(int idEC) {
        String res = "Aucune information!";
        BDInteraction bdi = new BDInteraction();
        res = bdi.getLibelleEC(idEC);
        if ("".equals(res)) {
            res = "Aucune information!";
        }

        return res;
    }

    public String afficherEC() {
//        this.contribution = this.infoBulle(this.getId());

        String enseignant ="", hCM = "", hTD = "", hTP = "", hMemoire = "", hStage = "", hPerso = "";
        if (this.getVolumeHeureCm() > 0) {
            hCM = ", CM: " + this.getVolumeHeureCm() + "h";
        }
        if (this.getVolumeHeureTd() > 0) {
            hTD = ", TD: " + this.getVolumeHeureTd() + "h";
        }
        if (this.getVolumeHeureTp() > 0) {
            hTP = ", TP: " + this.getVolumeHeureTp() + "h";
        }
        if (this.getVolumeHeurMemoire() > 0) {
            hMemoire = ", Mémoire: " + this.getVolumeHeurMemoire() + "h";
        }
        if (this.getVolumeHeureStage() > 0) {
            hStage = ", Stage: " + this.getVolumeHeureStage() + "h";
        }
        if (this.getVolumeHeurePerso() > 0) {
            hPerso = ", Perso: " + this.getVolumeHeurePerso() + "h";
        }
        if(this.getPrenomResponsable() != null && this.getNomResponsable() != null){
            enseignant = "<div>enseignant responsable: "+this.getPrenomResponsable()+" "+this.getNomResponsable()+"</div>";
        }
        String resultat = "<li id=\"EC"+this.getId()+"\" style=\"font-style:italic;\">"
                        + "<strong> EC :"+this.getLibelleComplet()+" ["+this.getCodeApogee()+"]</strong> (ECTS "+this.getNbCredit()+hCM+hTD+hTP+hMemoire+hStage+hPerso+")" +" <img src=\"images/info.jpg\" width=\"18px\" class=\"toto\" onmouseover=\"afficherTooltip('"+this.getId()+"');\" />"
//                + "<strong> EC :"+this.getLibelleComplet()+" ["+this.getCodeApogee()+"]</strong> (ECT:"+this.getNb_credit()+" | Heure "+hCM+hTD+hTP+hMemoire+hStage+hPerso+")" +" <img src=\"images/info.jpg\" width=18px class=\"link tooltip-link\" data-toggle=\"tooltip\" data-title=\""+this.contribution+"\" data-html=\"true\" />"
                        + enseignant
                        + "</li>";
        return resultat;
    }
    
    

    public String afficherECRecherche() {
        String enseignant ="", hCM = "", hTD = "", hTP = "", hMemoire = "", hStage = "", hPerso = "";
        if (this.getVolumeHeureCm() > 0) {
            hCM = ", CM: " + this.getVolumeHeureCm() + "h";
        }
        if (this.getVolumeHeureTd() > 0) {
            hTD = ", TD: " + this.getVolumeHeureTd() + "h";
        }
        if (this.getVolumeHeureTp() > 0) {
            hTP = ", TP: " + this.getVolumeHeureTp() + "h";
        }
        if (this.getVolumeHeurMemoire() > 0) {
            hMemoire = ", Mémoire: " + this.getVolumeHeurMemoire() + "h";
        }
        if (this.getVolumeHeureStage() > 0) {
            hStage = ", Stage: " + this.getVolumeHeureStage() + "h";
        }
        if (this.getVolumeHeurePerso() > 0) {
            hPerso = ", Perso: " + this.getVolumeHeurePerso() + "h";
        }
        if(this.getPrenomResponsable() != null && this.getNomResponsable() != null){
            enseignant = "<div>enseignant responsable: "+this.getPrenomResponsable()+" "+this.getNomResponsable()+"</div>";
        }
        String resultat = "<li id=\"EC"+this.getId()+"\" style=\"font-style:italic;\">"
                        + "<strong class=\"libelleRecherche\"> EC :"+this.getLibelleComplet()+" ["+this.getCodeApogee()+"]</strong> (ECTS "+this.getNbCredit()+hCM+hTD+hTP+hMemoire+hStage+hPerso+")" +" <img src=\"images/info.jpg\" width=\"18px\" class=\"toto\" onmouseover=\"afficherTooltip('"+this.getId()+"');\" />"
                        + enseignant
                        + "</li>";
        return resultat;
    }
}